import 'package:cbec_app/components/base/base_page.dart';
import 'package:cbec_app/components/base/base_nav_bar.dart';
import 'package:cbec_app/components/common/not_found.dart';
import 'package:cbec_app/components/order/bargining_order_item.dart';
import 'package:cbec_app/components/order/group_order_item.dart';
import 'package:cbec_app/pages/my/controller/bargaining_order_ctr.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class BargainingOrder extends GetView<BargainingOrderController> {


  BargainingOrder({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<BargainingOrderController>(builder: (controller){
      return BasePage(
      title: "我的砍价",
      iconType: IconType.back,
      isShowPadding: true,
      tabHeight: 40.w,
      tabBgColor: Tools.fromHex("#F3F5F7"),
      tabChildren: [
        _topTabbar()
      ],
      refreshController: controller.baseRefreshCtr,
      enablePullDown: true,
      enablePullUp: controller.hasNextPage,
      onPageLoading: controller.onPageLoading,
      onPageRefresh: controller.onPageRefresh,
      children: [
        Container(
          child: controller.orderList.isNotEmpty? ListView(
            shrinkWrap: true,
            physics: const NeverScrollableScrollPhysics(),
            //这里是订单
            children: List.generate(controller.orderList.length, (index){
              final Map item = controller.orderList[index];
              return BargainOrderItem(orderSn: item['haggleId'].toString(), orderTime: "1212", totalAmount: item['price'], status: item["haggleStatus"], goodsList: [
                {
                "img":item['img'],
                "title":item['goodsName'],
                "num":1,
                "price":item["price"],
                "tages":["保税"]
              }
              ], id:item["orderId"].toString(), haggleId: item['haggleId'],priceLeft: item['priceLeft']);
            })
            
          ):const NotFound(),
        )
      ],
    );
    });
  }


  Widget _topTabbar()=>Container(
          margin: EdgeInsets.only(top: 10.w),
          height: 25,
          child: TabBar(
              dividerColor: Colors.transparent,
              indicator:  BoxDecoration(
                border: Border(
                  bottom: BorderSide(width: 0.8, color: Tools.fromHex("#F83F2D")),
                ),
              ),
              labelColor: Colors.red,
              labelStyle: TextStyle(fontSize: 12,fontWeight: FontWeight.w500,color: Tools.fromHex("#999999")),
              unselectedLabelColor: Tools.fromHex("#999999"),
              
              controller: controller.tabController,
              tabAlignment: TabAlignment.fill,
              tabs: const [
                Tab(
                  text: "全部",
                ),
                Tab(
                  text: "砍价中",
                ),
                Tab(
                  text: "砍价成功",
                ),
                Tab(
                  text: "砍价失败",
                ),
              ]),
        );
}